function [model]=M_step_fdebug(model, data, MAXMSTEPITER, MaxFun, maxvalue, countVEM)

%global model;

MINDIFF   = 0.005;
conv_diff = 100000000;
count     = 0;

value0 = maxvalue;

model=update_alpha_01(model);
value1 = cal_likelihood(model, data);

  if (compareval(value1, maxvalue))
        maxvalue = value1;
        %disp('correct');
  else
        disp('Incorrect');
        keyboard;
  end

%model=update_alpha_02(model);
% value2 = cal_likelihood(model, data);
% 
%   if (compareval(value2, maxvalue))
%         maxvalue = value2;
%         disp('correct');
%   else
%         disp('Incorrect');
%         keyboard;
%   end

model=update_sigma_01(model);
value3 = cal_likelihood(model, data);

  if (compareval(value3, maxvalue))
        maxvalue = value3;
        %disp('correct');
  else
        disp('Incorrect');
        keyboard;
  end

model=update_beta_1(model, data);
value4 = cal_likelihood(model, data);

  if (compareval(value4, maxvalue))
        maxvalue = value4;
        disp('correct');
  else
        disp('Incorrect');
        keyboard;
  end

%model=update_beta_2(model, data);
  value5 = cal_likelihood(model, data);

  if (compareval(value5, maxvalue))
        maxvalue = value5;
        disp('correct');
  else
        disp('Incorrect');
        keyboard;
  end


while(conv_diff>MINDIFF && count<MAXMSTEPITER)

 disp('count from M-step');
 count = count+1

 %model=update_sigma_02(model, MaxFun);
%  value6 = cal_likelihood(model, data);
%  
%    if (compareval(value6, maxvalue))
%         maxvalue = value6;
%         disp('correct');
%    else
%         disp('Incorrect');
%         keyboard;
%    end
  
 %model=update_eta(model, MaxFun);
 value7 = cal_likelihood(model, data);
 
   if (compareval(value7, maxvalue))
        maxvalue = value7;
        disp('correct');
   else
        disp('Incorrect');
        keyboard;
   end
 
 conv_diff=abs(value5-value7)/abs(value5);
 value5=value7;

end

end
